package org.budo.netty.servlet.server.exception.handler;

import javax.servlet.http.HttpServletResponse;

import org.budo.netty.servlet.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author li
 */
public class DefaultExceptionHandler implements ExceptionHandler {
    private static final Logger log = LoggerFactory.getLogger(DefaultExceptionHandler.class);

    @Override
    public void handleException(HttpServletResponse response, Throwable e) {
        log.error("#23 exceptionCaught, response=" + response + ", e=" + e, e);

        response.setStatus(500);
        ResponseUtil.write(response, "<h1>ERROR: " + e + "</h1>");
    }
}